<%@ page session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>

<h:panelGroup>
        <fieldset>
        <legend>Lista textów</legend>
                <tr:commandLink shortDesc="Dodaj nowy tekst" immediate="true"
                					rendered="#{currentUserTO.currentSalesman.permissionMap.TEXT_ADD}" 
                                  	action="#{NavigationUtil.goToTextForm}"
                                  	inlineStyle="margin-left:5px">
                   <tr:image source="gfx/add32.png" />
                </tr:commandLink>
                                  	
                <tr:commandLink shortDesc="Edytuj zaznaczony tekst (tylko jeden)"
                				rendered="#{currentUserTO.currentSalesman.permissionMap.TEXT_EDIT}" 
                				inlineStyle="margin-left:5px"
                				action="#{textController.updateText}">
                    <tr:image source="gfx/edit32.png" />
                </tr:commandLink>
                <tr:commandLink shortDesc="Usuń zaznaczone"
                				rendered="#{currentUserTO.currentSalesman.permissionMap.TEXT_REMOVE}" 
                				action="#{textController.removeText}"
                				inlineStyle="margin-left:5px"
                            	onclick="return confirmMessageBox('Czy chcesz usunąć wszystkie zaznaczone teksty ?');">
                <tr:image source="gfx/delete32.png" />
            </tr:commandLink>
            <tr:commandLink inlineStyle="margin:5px" rendered="#{not empty invitationBean}" immediate="true"
							shortDesc="Dodaj zaznaczone teksty do zaproszenia"
							action="#{textController.addTextToInvitation}">
							<tr:image source="gfx/select32.png" />
			</tr:commandLink>

    <tr:table verticalGridVisible="false" horizontalGridVisible="false" rowBandingInterval="1"
              binding="#{textController.textListDataTable}" width="100%" inlineStyle="margin-top:10px"
              rendered="#{not empty textController.textList}" rowSelection="multiple"
              value="#{textController.textList}" var="text" rows="40">
      <tr:column sortProperty="type" sortable="true">
            <f:facet name="header">
                <h:outputText value="rodzaj tekstu" />
            </f:facet>
            <tr:selectOneChoice value="#{text.type}" readOnly="true">
                <f:selectItems value="#{ConstantDictionaries.textType}" />
            </tr:selectOneChoice>
        </tr:column>
        <tr:column sortProperty="code" sortable="true" width="100">
            <f:facet name="header">
                <h:outputText value="kod"/>
            </f:facet>
            <h:outputText value="#{text.code}"/>
        </tr:column>
        <tr:column inlineStyle="text-align:center" shortDesc="#{text.description}">
            <f:facet name="header">
                <h:outputText value="treść"/>
            </f:facet>
            <h:outputText value="#{text.content}"/>
        </tr:column>
    </tr:table>
   </fieldset>
</h:panelGroup>